package cn.xuchunh.exam;

import java.util.Scanner;

/**
 * Created by XuChunH on 2016/9/9.
 */
public class LuckNumber {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] source = new String[10];
        String target = "Petr";
        int num = 0;
        boolean isValid = false;
        for (int i = 0; i < 10; i++) {
            source[i] = scanner.next();
            boolean b =  target.equals(source[i]);
            isValid |= b;
            if(!b && target.compareTo(source[i]) > 0) {
                num++;
            }

        }
        num = isValid ? num + 1 : 0;
        System.out.println(num);
    }

}
